<?php
	namespace org\kahikai\database\mysql;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Cp1252"/>
<meta name="author" content="Ch4mp"/>
<link rel="shortcut icon" href="../../../../../favicon.ico" type="image/x-icon"/> 
<link rel="icon" href="../../../../../favicon.ico" type="image/x-icon"/>
<title>MysqlDevelopmentStepDao test</title>
</head>
<body>
<?php
	require_once '../../../../../org/kahikai/database/fs/FsPictureDao.php';
	require_once '../../../../../org/kahikai/database/mysql/MysqlDevelopmentDao.php';
	
	use org\kahikai\database\fs\FsPictureDao;
	use org\kahikai\database\mysql\MysqlDevelopmentDao;
	
	$picDao = new FsPictureDao();
	$devStepDao = new MysqlDevelopmentDao($picDao);
	
	echo "<h1>getBySpeciesId(2)</h1>\n";
	$step = $devStepDao->getBySpeciesId(2);
	echo "<p>" . chain2str($step) . "</p>\n";
	
	echo "<h1>getBySpeciesId(-1)</h1>\n";
	$step = $devStepDao->getBySpeciesId(-1);
	echo "<p>" . chain2str($step) . "</p>\n";
	
	function chain2str($step) {
		$str = step2str($step);
		while(isset($step->next)) {
			$step = $step->next;
			$str .= ' => ' . step2str($step);
		}
		return $str;
	}
	
	function step2str($step) {
		if($step == null) {
			return 'null';
		}
		$pic = $step->picture;
		$url = isset($pic) ? $pic->url : null;
		$str =  $step->name;
		if(isset($url)) {
			$str .= "<img src=\"../../../../../$url\" alt=\"$url\"/>";
		}
		return $str;
	}
?>
</body>
</html>